import { downloadHandle } from '#/utils/utils';
import { TRAlert, PLoading } from '#/components';
import { exportExcel } from '#/services/general';

export default async (params) => {
  PLoading.show('正在导出...');
  let data = await exportExcel(params);
  if (data.data && data.data instanceof Blob) {
    PLoading.dismiss();
    const realFileName = data.response.headers.get('content-disposition').split('filename=')[1];
    downloadHandle(data.data, decodeURI(realFileName));
  } else {
    PLoading.dismiss();
    TRAlert.error(data?.message || '请求失败');
  }
  PLoading.dismiss();
};
